package servlets;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import managers.DatabaseManager;

public class ActivateUser extends HttpServlet{
	private static final long serialVersionUID = 1L;

	protected void doPut(HttpServletRequest request, HttpServletResponse response){
		String idUser;
		idUser = request.getParameter("userId");
		
		DatabaseManager databaseManager;
		databaseManager = new DatabaseManager();
		databaseManager.connect();
		try {
			databaseManager.activateUser(idUser);
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		databaseManager.closeConnection();
		response.setContentType("application/json");
		response.setCharacterEncoding("UTF-8");
		try {
			response.getWriter().write("Activated");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
